<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath %>" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>控制台</title>
	
	<jsp:include page="./common/include.jsp"></jsp:include>
	<style type="text/css">
	#res p {
		margin: 2px 0px;
		font-size: 11pt;
		font-family: 'Courier New';
	}
	</style>
</head>
<body>
	<!--
    <input type="text" id="msg"/><br/>
   	<input type="submit" id="send"/><br/>
   	 -->
   	<h3>部署日志</h3>
   	<hr/>
   	<div id="res">
   	
   	</div>
   	<div id="end">&nbsp;&nbsp;</div>
   	
	<script type="text/javascript">
	var ws;
	$(function() {
		//ws = new WebSocket("ws://localhost:8080/flash/msgServer");
		ws = new WebSocket("ws://172.22.12.229:8480/flash/msgServer");
		ws.onopen = function() {
			
		};
		ws.onmessage = function(event) {
			var msg = event.data;
			if(msg.indexOf('Exception') >= 0) {
				$('#res').append('<p style="color:red;">'+event.data + '</p>');
			} else if(msg.indexOf('---------------') >= 0){
				$('#res').append('<p style="color:blue;">'+event.data + '</p>');
			} else if(msg.indexOf('done') >= 0) {
				$('#res').append('<p style="color:green;">'+event.data + '</p>');
			} else if(msg.indexOf('Success') >= 0) {
				$('#res').append('<p style="color:green;">'+event.data + '</p>');
			} else {
				$('#res').append('<p>'+event.data + '</p>');
			}
		};
		ws.onclose = function() {
			
		};
		ws.onerror = function() {
			
		};
		
		$('#send').click(function() {
			var msg = $('#msg').val();
			ws.send(msg);
		});
	});
	</script>
</body>
</html>